package LeetCode;

import org.omg.PortableInterceptor.INACTIVE;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}16:23
 */
public class LeetCode11 {
    public int maxArea(int[] height) {
        int max = 0;
        for (int i = 0; i < height.length; i++){
            for (int j = i+1; j < height.length; j++){
                max = Math.max(max, Math.min(height[i],height[j])*(j - i));
            }
        }
        return max;
    }


    //对撞指针+动态规划
    public int maxArea2(int[] height) {
        int max =0;
        int left = 0;
        int right = height.length - 1;
        while (left < right) {
            max = Math.max(max,Math.min(height[right],height[left])*(right - left));
            if (height[left] >= height[right]){
                right--;
            }else {
                left++;
            }
        }
        return max;
    }
}
